package com.zhouxujing.game;

import java.awt.Graphics;
import java.awt.Image;
//血条类
public class Blood extends Animation {

	private static Image[] imgs = new Image[6];
	public static int count=5;//血条是一组动图，5个转态
	public static int buckle =1;//受攻击扣的血量
    static {
        for(int i=0;i<6;i++){
        	//运用gameutil类获取血条图片，存入一个image数组
            imgs[i] = GameUtil.getImage("images/blood/blood"+(i+1)+".png");
            imgs[i].getWidth(null);
        }
    }
    public Blood() {
    	
	}
    //绘制血条坐标横轴400，纵轴40
	public void draw(Graphics g) {
		g.drawImage(imgs[count], 400, 10, null);
	}
	//下面为两个增加和减少血条的方法
	public void addBlood(){
		if(count<5)count+=buckle;
		if (count>=5) {
			count=5;
		}
	}
	public void minusBlood(){
		if(count>0)count-=buckle;
		if (count==0) {
			
			MyGameFrame mgf = new MyGameFrame();
			System.out.println("我方飞机血条空");
			mgf.state = 3;
		}
	}
}
